<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<c:set value="${c.module.moduleName}" var="moduleName" scope="request" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>${c.title}列表</title>
	</head>
	<body>
		<form action="<c:url value='/console/${c.module.moduleName}/${c.name?uncap_first}.do'/>" method="post">
			<#assign trCount = 0>
			<#list c.properties as p>
			<#if p.search == "true">
			<#assign trCount = trCount + 1>
			<#if trCount == 1>
			<table class="table-layout">
			</#if>
				<tr class="<#if trCount%2 == 1>tr-odd<#else>tr-even</#if>">
					<td class="td-label">
						${p.element.title}
					</td>
					<td>
						<#if p.type == "String">
						<input type="text" name="filter_LIKES_${p.name}" value="<c:out value="${"$"}{filters.LIKES_${p.name}}" />" />
						<#elseif p.type == "Long">
						<input type="text" name="filter_EQS_L${p.name}" value="<c:out value="${"$"}{filters.EQS_L${p.name}}" />" />
						</#if>
					</td>
				</tr>
			</#if>
			</#list>
			<#if trCount != 0>
			</table>
			</#if>
			<div class="right-opertion">
				<input type="button" value="搜索" onclick="search(this);" class="button" />
			</div>
			<br />
			<table class="table-layout">
				<tr class="tr-thead">
					<th>
						ID
					</th>
					<#list c.properties as p>
					<#if p.show == "true">
					<th>
						<a href="javascript:void(0);" onclick="javascript:sort('${p.name}',this)">${p.element.title}</a>
					</th>
					</#if>
					</#list>
					<#list c.oneToOne as o>
					<th>
						${c.findClass(o.className,config).title}
					</th>
					</#list>
					<#list c.oneToMany as om>
					<th>
						${c.findClass(om.className,config).title}
					</th>
					</#list>
					<#list c.manyToOne as mo>
					<th>
						${c.findClass(mo.className,config).title}
					</th>
					</#list>
					<authz:authorize ifAnyGranted="admin,role_${c.module.moduleName}_admin">
					<th>
						操作
					</th>
					</authz:authorize>
				</tr>
				<logic:present name="page">
				<logic-el:iterate name="page" property="result" id="${c.name?uncap_first}" indexId="index">
					<tr class="<c:if test="${"$"}{index % 2 == 0}">tr-odd</c:if><c:if test="${"$"}{index % 2 == 1}">tr-even</c:if>">
						<td>
							<c:out value="${"$"}{${c.name?uncap_first}.id}" />
							&nbsp;
						</td>
						<#list c.properties as p>
						<#if p.show == "true">
						<td>
							<#if p_index == 0>
							<a href="<c:url value='${c.name?uncap_first}.do?method=view&id=${"$"}{${c.name?uncap_first}.id}'/>"><c:out value="${"$"}{${c.name?uncap_first}.${p.name}}" /></a>
							<#else>
							<c:out value="${"$"}{${c.name?uncap_first}.${p.name}}" />
							</#if>
							&nbsp;
						</td>
						</#if>
						</#list>
						<#list c.oneToOne as o>
						<td>
							<c:choose>
								<c:when test="${"$"}{${c.name?uncap_first}.${o.name} != null && ${c.name?uncap_first}.${o.name}.status == 1}">
									<#assign pcount = 1>
									<#list c.findClass(o.className,config).properties as p>
									<#if p.show == "true" && pcount == 1>
									<#assign pcount = pcount + 1>
									<a href="<c:url value='${o.className?uncap_first}.do?method=edit&id=${"$"}{${c.name?uncap_first}.${o.name}.id}'/>"><c:out value="${"$"}{${c.name?uncap_first}.${o.name}.${p.name}}" /></a>
									</#if>
									</#list>
								</c:when>
								<c:otherwise>
									<authz:authorize ifAnyGranted="admin,role_${c.module.moduleName}_admin">
									<input type="button" onclick="location.href='<c:url value='${o.className?uncap_first}.do?method=edit&${o.className?uncap_first}Id=${"$"}{${o.className?uncap_first}.id}'/>'" value="添加" />
									</authz:authorize>
								</c:otherwise>
							</c:choose>
							&nbsp;
						</td>
						</#list>
						<#list c.oneToMany as om>
						<td>
							<logic:notEmpty name="${c.name?uncap_first}" property="${om.name}">
								<a href="<c:url value='${om.className?uncap_first}.do?method=list&filter_EQS_L${c.name?uncap_first}_id=${"$"}{${c.name?uncap_first}.id}'/>">${c.findClass(om.className,config).title}</a>
							</logic:notEmpty>
							&nbsp;
						</td>
						</#list>
						<#list c.manyToOne as mo>
						<td>
							<c:if test="${"$"}{${c.name?uncap_first}.${mo.name} != null}">
								<#assign pcount = 1>
								<#list c.findClass(mo.className,config).properties as p>
								<#if p.show == "true" && pcount == 1>
								<#assign pcount = pcount + 1>
								<a href="<c:url value='${mo.className?uncap_first}.do?method=edit&id=${"$"}{${c.name?uncap_first}.${mo.name}.id}'/>"><c:out value="${"$"}{${c.name?uncap_first}.${mo.name}.${p.name}}" /></a>
								</#if>
								</#list>
							</c:if>
							&nbsp;
						</td>
						</#list>
						<authz:authorize ifAnyGranted="admin,role_${c.module.moduleName}_admin">
						<td>
							<a href="<c:url value='${c.name?uncap_first}.do?method=edit&id=${"$"}{${c.name?uncap_first}.id}'/>">修改</a>&nbsp;
							<span class="link" onclick="if(confirm('确定要删除该记录吗？')) location.href='<c:url value='${c.name?uncap_first}.do?method=erase&id=${"$"}{${c.name?uncap_first}.id}'/>'">删除</span>&nbsp;
						</td>
						</authz:authorize>
					</tr>
				</logic-el:iterate>
				</logic:present>
			</table>
			<page:page name="page" />
		</form>
		<authz:authorize ifAnyGranted="admin,role_${c.module.moduleName}_admin">
		<br />
		<div class="center-opertion">
			<input type="button" onclick="location.href='<c:url value='${c.name?uncap_first}.do?method=edit'/>'" value="添加" />&nbsp;&nbsp;
		</div>
		</authz:authorize>
	</body>
</html>
